home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / os2 / strs_145.zip / INSTALL.CMD < prev    next >
OS/2 REXX Batch file  |  1996-04-20  |  5KB  |  193 lines

  1. /***************************************************/
  2. /* Installation Script for STris                   */
  3. /* (c) 1995-96 R. Straub                           */
  4. /***************************************************/
  5.  
  6. PrgName = 'STris'
  7. Version = '1.45'
  8.  
  9. CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'    /* Make REXX functions available */
  10. CALL SysLoadFuncs
  11.  
  12. PARSE Arg InstallDir                                         /* Command line parameter */
  13. SIGNAL On Halt Name ErrorHandler                            /* Error handler */
  14.  
  15. CALL SysCls
  16.  
  17. SAY
  18. SAY
  19. SAY " STris Installation "
  20. SAY " ------------------ "
  21.  
  22. IF InstallDir=" " THEN DO                                    /* If no path is given, get one from the user */
  23.     SAY
  24.     SAY " Please specify the full-path to the directory"
  25.     SAY " where you would like to install" PrgName " " Version
  26.     SAY " Hit <Enter> to use the current directory,"
  27.     SAY " or type 'Q'<Enter> to quit."
  28.     SAY
  29.     SAY " For Example:  E:\GAMES\STRIS<Enter>"
  30.     SAY
  31.     SAY " Please specify:"                                    /* Prompt for input */
  32.  
  33.     PARSE Value SysCurPos() with Row Col
  34.     Col = Col+17
  35.     Row = Row-1
  36.  
  37.     CALL SysCurPos Row, Col
  38.     PULL InstallDir
  39.     IF (InstallDir="Q") | (InstallDir="q") THEN EXIT        /* Quit if they hit 'Q' */
  40. END
  41.  
  42. SAY
  43.  
  44. CurrentDir = directory()                            /* Find the current directory */
  45.  
  46. IF (InstallDir=" ") Then InstallDir=CurrentDir        /* Set to the current directory if none given */
  47.  
  48. IF (CurrentDir\=directory(InstallDir)) THEN DO        /* If installing to different dir, do copying bit */
  49.  
  50.     Command = '@CD 'directory(CurrentDir)            /* Switch back to installation dir */
  51.     Command
  52.  
  53.     CALL CreateDir InstallDir
  54.  
  55.     SAY " Now copying files to "InstallDir" ..."    /* Now copy files */
  56.  
  57.     CALL FileMove 'STris.EXE', InstallDir
  58.     CALL FileMove 'STris.HLP', InstallDir
  59.     CALL FileMove 'STris.INI', InstallDir
  60.     CALL FileMove 'STris.HSC', InstallDir
  61.  
  62.     CALL FileMove 'Glass.WAV', InstallDir
  63.     CALL FileMove 'Ding.WAV', InstallDir
  64.     CALL FileMove 'BreakIt.WAV', InstallDir
  65.  
  66.     CALL FileMove 'File_ID.DIZ', InstallDir
  67.     CALL FileCopy 'Read.Me', InstallDir
  68. END
  69.  
  70.  
  71. SAY " Creating WPS program object ..."                    /* Create WPS-Desktop object */
  72.  
  73. LastChar = substr(InstallDir,length(InstallDir),1)        /* See if directory terminates in a \ */
  74.  
  75. IF LastChar = "\" THEN SetupString="EXENAME="InstallDir"STris.exe;STARTUPDIR="InstallDir
  76. ELSE                   SetupString="EXENAME="InstallDir"\STris.exe;STARTUPDIR="InstallDir
  77.  
  78. rc=SysCreateObject("WPProgram",PrgName" "Version,"<WP_DESKTOP>",SetupString,UPDATE)
  79. IF rc=0 THEN DO
  80.   SAY
  81.   SAY " WARNING : Couldn't create program object on WPS."
  82. /*  EXIT  */
  83. END
  84.  
  85. SAY " Now you get to read the ReadMe file ..."
  86.  
  87. Command='@E Read.Me'                                    /* Look at the README.TXT */
  88. Command
  89.  
  90. CALL FileDelete 'Read.Me'
  91. CALL FileDelete 'Install.CMD'
  92.  
  93. SAY
  94. SAY " STris has been successfully installed. Have fun ..."
  95.  
  96. EXIT
  97.  
  98.  
  99.  
  100.  
  101. /***************************************************/
  102. /* File Move                                       */
  103. /***************************************************/
  104.  
  105. FileMove: Arg FileName, Destination
  106.  
  107. /*    SAY "FileCopy " FileName " " Destination */
  108.     CALL FileCopy FileName, Destination
  109.     CALL FileDelete FileName
  110.  
  111. RETURN
  112.  
  113.  
  114.  
  115.  
  116. /***************************************************/
  117. /* File Copy                                       */
  118. /***************************************************/
  119.  
  120. FileCopy: Arg FileName, Destination
  121.  
  122.   Command='@Copy 'FileName' 'Destination' >NUL'
  123.   Command
  124.  
  125.   IF rc\=0 THEN DO                                        /* Error copying file */
  126.     SAY " ERROR : Failed to copy file "FileName". Installation aborted ..."
  127.     EXIT
  128.   END
  129.  
  130. RETURN
  131.  
  132.  
  133.  
  134. /***************************************************/
  135. /* File Delete                                     */
  136. /***************************************************/
  137.  
  138. FileDelete: Arg FileName
  139.  
  140.   rc=SysFileDelete(FileName)
  141.   IF rc\=0 THEN DO
  142.     SAY " ERROR : Failed to delete file "FileName". Installation aborted ..."
  143.     EXIT
  144.   END
  145.  
  146. RETURN
  147.  
  148.  
  149.  
  150. /***************************************************/
  151. /* CreateDir                                       */
  152. /***************************************************/
  153.  
  154. CreateDir: Arg DirName
  155.  
  156.   CALL SysFileTree DirName, FileDirectory, 'D'    /* Search for new directory */
  157.  
  158.   IF FileDirectory.0='0' THEN DO                /* If not found, create it */
  159.     SAY " Now creating directory "DirName
  160.  
  161.     rc=SysMkDir(DirName)
  162. /*    SAY "SysMkDir :" rc "."  */
  163.  
  164.     IF rc\=0 THEN DO
  165.       SAY
  166.       SAY " ERROR : The directory " DirName " couldn't be created,"
  167.       SAY " probably because you specified an invalid directory name"
  168.       SAY " or the destination disk is write-protected."
  169.       SAY " Installation aborted."
  170.       EXIT
  171.     END
  172.  
  173.   END
  174.   ELSE
  175.     SAY " Using existing directory " DirName
  176.  
  177. RETURN
  178.  
  179.  
  180.  
  181. /***************************************************/
  182. /* Error handler                                   */
  183. /***************************************************/
  184.  
  185. ErrorHandler:
  186.  
  187.   CALL SysCls
  188.   SAY " Error while installing STris ! Installation aborted ..."
  189.  
  190. EXIT
  191.  
  192.  
  193.